window.onload = function(){
  addPic(fileElem,fileList);
  addPic(fileElem2,fileList2);
  addPic(fileElem3,fileList3);
  addPic(fileElem4,fileList4);
  addPic(fileElem5,fileList5);
}

 window.URL = window.URL || window.webkitURL;
    var fileElem = getId('file_input'),
    fileList = getId("fileList"),
    fileElem2 = getId('file_input2'),
    fileList2 = getId("fileList2"),
    fileElem3 = getId('file_input3'),
    fileList3 = getId("fileList3"),
    fileElem4 = getId('file_input4'),
    fileList4 = getId("fileList4"),
    fileElem5 = getId('file_input5'),
    fileList5 = getId("fileList5");

    function handleFiles(obj,target) {
        var files = obj.files,
        img = new Image();
        if(window.URL){
            img.src = window.URL.createObjectURL(files[0]); //创建一个object URL，并不是你的本地路径
            img.width = 200;
            img.height = 140;
            img.onload = function(e) {
                window.URL.revokeObjectURL(this.src); //图片加载后，释放object URL
            }
            target.appendChild(img);
        }else if(window.FileReader){
            //opera不支持createObjectURL/revokeObjectURL方法。我们用FileReader对象来处理
            var reader = new FileReader();
            reader.readAsDataURL(files[0]);
            reader.onload = function(e){
                alert(files[0].name + "," +e.total + " bytes");
                img.src = this.result;
                img.width = 200;
                img.height = 140;
                target.appendChild(img);
            }
        }else{
            //ie
            obj.select();
            obj.blur();
            var nfile = document.selection.createRange().text;
            document.selection.empty();
            img.src = nfile;
            img.width = 200;
            img.onload=function(){
                alert(nfile+","+img.fileSize + " bytes");
            }
            target.appendChild(img);
        }
    }

function getId(str){
  return document.getElementById(str);
}

function addPic(fileE,fileL){
  fileE.onchange = function(){
    if(fileL.childNodes != 0){
      var childs = fileL.childNodes;
      for(var i = 0; i<childs.length;i++){
        fileL5.removeChild(childs[i]);
      }
    };
    handleFiles(fileE,fileL);
  }
}
